<template>
	<div class="icons">
		<swiper :options="swiperOption">
			<swiper-slide v-for="(page,index) of pages" :key="index">
				<div class="icon" v-for="item of page" :key="item.id">
					<a href="#">
						<div class="icon-img">
							<img :src="item.imgUrl" alt="">
						</div>
						<div class="icon-desc">{{item.desc}}</div>						
					</a>
				</div>
			</swiper-slide>
			<div class="swiper-pagination" slot="pagination"></div>
		</swiper>		
	</div>
</template>

<script>
export default {
	name:'HomeIcons',
	props:{
		list:Array
	},
	data() {
		return {
			swiperOption:{
				pagination: '.swiper-pagination',
				autoplay: false,
				loop: false
			}
		}
	},
	computed: {
		pages() {
			const pages = [];
			this.list.forEach((item,index) => {
				const page = Math.floor(index/8);
				if(!pages[page]){
					pages[page] = [];
				}
				pages[page].push(item);
			})
			return pages
		}
	}
}	
</script>

<style lang="stylus" scoped>
	@import "~styles/variable.styl"
	@import "~styles/mixins.styl"

	.icons >>> .swiper-pagination-bullet
		width: .12rem
		height: .12rem
	.icons >>> .swiper-pagination-bullet-active
		background:#00bcd4
	.icons >>> .swiper-wrapper
		padding-bottom:.4rem
	.icons >>> .swiper-pagination-bullets
		bottom:0
	.icons
		padding:.1rem 0
		background:$white
		.icon
			float:left
			padding-top:.1rem
			width:25%
			text-align:center
			.icon-img
				img
					width:1.1rem
					height:1.1rem
			.icon-desc
				margin-top:.1rem
				line-height:.28rem
				color:#212121
				ellipsis()
</style>